package com.woniuxy.cloud.carl.marketing.app.apiImpl;

import cn.hutool.core.bean.BeanUtil;
import com.woniu.cloud.Aspect.log.Log;
import com.woniuxy.cloud.carl.marketing.client.ConponConditionClient;
import com.woniuxy.cloud.carl.marketing.client.param.AddCouponConditionpParam;
import com.woniuxy.cloud.carl.marketing.infra.model.ConponCondition;
import com.woniuxy.cloud.carl.marketing.service.ConditionCouponService;
import com.woniuxy.cloud.carl.marketing.service.ConponConditionService;
import com.woniuxy.result.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class ConponConditionAPIImpl implements ConponConditionClient {
    @Autowired
    ConponConditionService conponConditionService;
    @Override
    @Log("添加优惠券获取条件")
    public Result addCouponCondition(AddCouponConditionpParam param) {
        ConponCondition conponCondition = BeanUtil.copyProperties(param, ConponCondition.class);
        conponConditionService.save(conponCondition);
        return Result.success();
    }

    @Override
    @Log("查询优惠券获取条件")
    public Result<ConponCondition> getCouponCondition() {
        return Result.success(conponConditionService.list());
    }
}
